package com.xzz.finger;

/**
 * @author: hhz
 * @create: 2022-02-17 13:47
 * 剑指 Offer 05. 替换空格
 **/
public class ReplaceSpace {
    public static void main(String[] args) {
        System.out.println(replaceSpace("We are happy."));

    }
    public static String replaceSpace(String s) {
        StringBuilder sb = new StringBuilder();
        for (char c : s.toCharArray()) {
            if(c==' '){
                sb.append("%20");
            }else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}
